using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace SpomeCTypes
{
    public partial class CTDesigner : Form
    {
        string fields;
        public CTDesigner()
        {
            InitializeComponent();
        }

        private void myMenuSave_Click( object sender, EventArgs e )
        {
            if ( saveFileDialog1.ShowDialog() == DialogResult.OK )
            {
                if ( !string.IsNullOrEmpty( saveFileDialog1.FileName ) )
                {
                    System.IO.StreamWriter sw = new System.IO.StreamWriter( saveFileDialog1.OpenFile() );
                    sw.Write( fields );
                    sw.Close();
                    MessageBox.Show( string.Format( "The fields we saved sucessfully in {0}", saveFileDialog1.FileName ) );
                }
            }
        }

        private void myMenuOpen_Click( object sender, EventArgs e )
        {
            if ( openFileDialog1.ShowDialog() == DialogResult.OK )
            {
                string fileName = openFileDialog1.FileName.Substring( openFileDialog1.FileName.LastIndexOf( "\\" ) + 1 );

                System.IO.StreamReader sr = new System.IO.StreamReader( openFileDialog1.FileName );
                fields = sr.ReadToEnd();
                //XmlTextReader myXml = new XmlTextReader(
                this.tabFields.TabPages.Add( fileName, fileName );
                TabPage page = this.tabFields.TabPages[ fileName ];
                TreeView tree = new TreeView();
                tree.Scrollable = true;
                tree.Width = page.Width;
                tree.Height = page.Height;
                page.Controls.Add( tree );
                sr.Close();
            }
        }

    }
}